package com.sanpu.kxe.business.main.adapter;

import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.sanpu.kxe.R;
import com.sanpu.kxe.business.main.bean.MaterialVideoOutput;
import com.sanpu.kxe.common.interfaces.UrlConstants;
import com.sanpu.kxe.jump.imageloader.JKImageLoader;

import java.util.ArrayList;

/**
 * Description：推广视频
 * Created by 薛勇军 on 2019/9/27.
 */

public class MaterialVideoAdapter extends BaseQuickAdapter<MaterialVideoOutput, BaseViewHolder> {

    public MaterialVideoAdapter() {
        super(R.layout.item_material_video, new ArrayList<MaterialVideoOutput>());
    }

    @Override
    protected void convert(BaseViewHolder helper, MaterialVideoOutput item) {
        ImageView imageIv = helper.getView(R.id.imageIv);
        TextView titleTv = helper.getView(R.id.titleTv);
        View topLineView = helper.getView(R.id.topLineView);
        helper.addOnClickListener(R.id.shareIv);

        if (item != null) {
            JKImageLoader.getInstance().displayImage(
                    mContext, UrlConstants.getBaseUrl() + item.getImage(), imageIv);
            if (!TextUtils.isEmpty(item.getTitle())) {
                titleTv.setText(item.getTitle());
            }
            if (helper.getLayoutPosition() == 0) {
                topLineView.setVisibility(View.VISIBLE);
            } else {
                topLineView.setVisibility(View.GONE);
            }
        }
    }
}
